Skip to content

Commit

Permalink
Merge pull request #152 from mongodb-developer/feature/enable-swagger
Browse files Browse the repository at this point in the history
enable swagger;
  • Loading branch information
ctcac00 authored Nov 27, 2024
2 parents 2f2fb3b + 6fa6b0a commit 39a7310
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions rest_service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Add services to the container.

builder.Services.AddControllers();

// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();

Expand All @@ -14,20 +15,17 @@

builder.Services.AddCors(options =>
{
options.AddPolicy("NewPolicy", builder =>
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader());
options.AddPolicy(
"NewPolicy",
builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()
);
});

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseSwagger();
app.UseSwaggerUI();

app.UseHttpsRedirection();
app.UseCors("NewPolicy");
Expand All @@ -38,4 +36,5 @@
// Register custom serializers
BsonSerializer.RegisterSerializer(new RecordingPlayerSerializer());
BsonSerializer.RegisterSerializer(new RecordingEventSerializer());
app.Run();
app.Run();

0 comments on commit 39a7310

Please sign in to comment.